new Vue({
	el: '.container',
	data: {
		limitNum: 3,
		addressList: [],
		currentIndex: 0,
		shippingMethod: 1,
		addFlag: false,
		delFlag: false,
		address: {
			"addressId": "",
			"userName": "",
			"streetName": "",
			"postCode": "",
			"tel": "",
			
			"isDefault": true
		},
		delare:''
	},
	mounted: function() {
		this.$nextTick(function() {
			this.getAddressList();
		});
	},
	computed: {
		filterAddress: function() {
			return this.addressList.slice(0, this.limitNum);
		}
	},
	methods: {
		getAddressList: function() {
			var _this = this;
			this.$http.get("data/address.json").then(function(response) {
				var res = response.data;
				if(res.status == "0") {
					_this.addressList = res.result;
				}
			});
		},
		loadMore: function() {
			this.limitNum = this.addressList.length;
		},
		setDefault: function(addressId) {
			this.addressList.forEach(function(address, index) {
				if(address.addressId == addressId) {
					address.isDefault = true;
				} else {
					address.isDefault = false;
				}
			});
		},
		addare: function() {
			//			this.addressList.splice(1,1);
			//			console.log(this.addressList);
			this.addressList.push(this.address);
			this.loadMore();
			this.addFlag = false;
			this.address = this.defadd();
		},
		delclick:function(item){
			this.delare = item;
			this.delFlag = true;
		},
		deladdress: function() {
			let index = this.addressList.indexOf(this.delare);
			this.addressList.splice(index,1);
			this.delFlag = false;
		},
		defadd: function() {
			return {
				"addressId": "",
				"userName": "",
				"streetName": "",66
				"postCode": "",
				"tel": "",
				"isDefault": true
			}
		}
	}
});

